// 借款人资质审核
app.controller('borrowcheck', ['$scope', 'commonFactory', 'toaster','$timeout', function ($scope, commonFactory, toaster,$timeout) {
    $scope.borrowcheckData = {
        Index: 1,
        Size: 10,
        Mobile: ''
    }
    //下一页
    $scope.next = function () {
        if ($scope.page) {
            if ($scope.borrowcheckData.Index >= $scope.page) {//判断最大页码
                $scope.borrowcheckData.Index = $scope.page;
                return false;
            }
            $scope.borrowcheckData.Index++
            requestborrowcheckList();
        }
    }
    //上一页
    $scope.prev = function () {
        if ($scope.borrowcheckData.Index <= 1) {//判断最小页码
            $scope.borrowcheckData.Index = 1;
            return false;
        }
        $scope.borrowcheckData.Index--;
        requestborrowcheckList()
    }
    // 查询
    $scope.queryBorr = function () {
        $scope.graybtn = true;
        $scope.borrowcheckData.Index = 1;
        requestborrowcheckList();
    }
    var requestborrowcheckList = function () {
        commonFactory.loading(true)
        commonFactory.ajax("/api/Borrow/QueryBorrowList", $scope.borrowcheckData, function (result) {
            commonFactory.loading(false)
            $scope.graybtn = false;
            if(result.Code==1){
                $scope.borrowCheckList = result.Data.Data;
                $scope.borrowCheckCount = result.Data.Count;
                $scope.page = Math.ceil(result.Data.Count / $scope.borrowcheckData.Size);
            }
        }, function () {
            commonFactory.loading(false)
            $scope.graybtn = false;
        }, "post");
    }
    requestborrowcheckList()
    //导出
    $scope.export = function () {
        var uId = localStorage.getItem('u_id')||'';
        $scope.gourl = commonFactory.baseurl + '/api/Borrow/Expoit?Mobile=' + $scope.borrowcheckData.Mobile + '&Size=' + $scope.borrowcheckData.Size + '&Index=' + $scope.borrowcheckData.Index + '&u_Id=' + uId;
    }
}]);